﻿using System.Windows;
using System.Windows.Input;
using FM.矩阵.控制.Event;
using FM.矩阵.控制.Models;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;

namespace FM.矩阵.控制.ViewModels
{
    public class 菜单ViewModel : BindableBase
    {
        public 菜单ViewModel()
        {
            新闻部 = FM.小冰.新闻部;
            退出Command = new DelegateCommand<object>(退出Action);
            状态查询Command = new DelegateCommand<object>(状态查询Action);
            控制视图Command = new DelegateCommand<object>(控制视图Action);
            启动监听Command = new DelegateCommand<object>(启动监听Action);
            关闭监听Command = new DelegateCommand<object>(关闭监听Action);
            设置监听Command = new DelegateCommand<object>(设置监听Action);
            查看日志Command = new DelegateCommand<object>(查看日志Action);
            定时任务编辑Command = new DelegateCommand<object>(定时任务编辑Action);
            任务单编辑Command = new DelegateCommand<object>(任务单编辑Action);
            快捷任务编辑Command = new DelegateCommand<object>(快捷任务编辑Action);

            系统设置Command = new DelegateCommand<object>(系统设置Action);

            点击关于Command = new DelegateCommand<object>(点击关于Action);

            保存布局Command = new DelegateCommand<object>(保存布局Action);

            协议管理Command = new DelegateCommand<object>(协议管理Action);

            通道管理Command = new DelegateCommand<object>(通道管理Action);

            指令管理Command = new DelegateCommand<object>(指令管理Action);
        }

        private void 控制视图Action(object obj)
        {
            新闻部.GetEvent<调用主界面Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "控制视图"));
        }

        private void 状态查询Action(object obj)
        {
            新闻部.GetEvent<状态查询Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "状态查询"));
        }

        private void 启动监听Action(object obj)
        {
            新闻部.GetEvent<启动监听Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "启动监听"));
        }

        private void 设置监听Action(object obj)
        {
            新闻部.GetEvent<设置监听Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "设置监听"));
        }

        private void 关闭监听Action(object obj)
        {
            新闻部.GetEvent<关闭监听Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "关闭监听"));
        }

        private void 查看日志Action(object obj)
        {
            新闻部.GetEvent<查看日志Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "查看日志"));
        }

        private void 定时任务编辑Action(object obj)
        {
            新闻部.GetEvent<定时任务编辑Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "定时任务编辑"));
        }


        private void 任务单编辑Action(object obj)
        {
            新闻部.GetEvent<任务单编辑Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "任务单编辑"));
        }

        private void 快捷任务编辑Action(object obj)
        {
            新闻部.GetEvent<快捷任务编辑Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "快捷任务编辑"));
        }

        private void 系统设置Action(object obj)
        {
            新闻部.GetEvent<系统设置Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", " 系统设置"));
        }

        private void 点击关于Action(object obj)
        {
            新闻部.GetEvent<点击关于Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "点击关于"));
        }

        private void 保存布局Action(object obj)
        {
            新闻部.GetEvent<保存布局Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "保存布局"));
        }


        private void 协议管理Action(object obj)
        {
            新闻部.GetEvent<协议管理Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "协议管理"));
        }

        private void 通道管理Action(object obj)
        {
            新闻部.GetEvent<通道管理Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", "通道管理"));
        }

        private void 指令管理Action(object obj)
        {
            新闻部.GetEvent<指令管理Event>().Publish(null);

            新闻部.GetEvent<状态更新Event>().Publish(new 状态栏Data("提示", " 指令管理"));
        }

        private void 退出Action(object obj)
        {
            Application.Current.Shutdown();
        }


        public IEventAggregator 新闻部 { get; set; }

        public ICommand 状态查询Command { get; set; }

        public ICommand 控制视图Command { get; set; }

        public ICommand 启动监听Command { get; set; }

        public ICommand 关闭监听Command { get; set; }

        public ICommand 设置监听Command { get; set; }

        public ICommand 查看日志Command { get; set; }

        public ICommand 定时任务编辑Command { get; set; }

        public ICommand 任务单编辑Command { get; set; }

        public ICommand 快捷任务编辑Command { get; set; }

        public ICommand 系统设置Command { get; set; }

        public ICommand 点击关于Command { get; set; }

        public ICommand 保存布局Command { get; set; }

        public ICommand 协议管理Command { get; set; }

        public ICommand 通道管理Command { get; set; }

        public ICommand 指令管理Command { get; set; }

        public ICommand 退出Command { get; set; }
    }
}